#include "stdafx.h"

#ifdef _DEBUG
#define new DEBUG_NEW
#endif
/////////////////////////////////////////////////////////////////////////////////////////////////
void calc_roc(tagUMyCalcFormula*pFormula,long numCalc,phistory_data paData,double*dataCalc[10],long decNum,long sec_type,_procReflection procReflection)
{
	double*fpRef=dataCalc[5];
	double*ROC=dataCalc[0],*MAROC=dataCalc[1];

	double*pcdClose=dataCalc[6];
	double seedPrice(__price_seed__[decNum]);
	for(long i=0;i<numCalc;++i)
		pcdClose[i] = paData[i].ClosePx/seedPrice;

	UMyCalc_REF(fpRef,pcdClose,numCalc,pFormula->infoParam[0].nowValue);
	UMyCalc_SUB(dataCalc[4],pcdClose,fpRef,numCalc);
	UMyCalc_DIV(ROC,dataCalc[4],fpRef,numCalc);
	UMyCalc_MUL2(ROC,100.0f,numCalc);

	memcpy(MAROC,ROC,numCalc*sizeof(double));
	UMyCalc_MA(MAROC,numCalc,pFormula->infoParam[1].nowValue);
}
/*
ROC:100*(CLOSE-REF(CLOSE,N))/REF(CLOSE,N);
MAROC:MA(ROC,M);
*/
